//
//  CustomCell.m
//  Project
//
//  Created by apple on 2018/12/6.
//  Copyright © 2018 apple. All rights reserved.
//

#import "CustomCell.h"
#import <Masonry.h>
@interface CustomCell ()
@property (nonatomic, strong)UILabel *titleLab;

@property (nonatomic, strong)UILabel *followLab;
@property (nonatomic, strong)UIButton *zhiBtn;
@property (nonatomic, strong)UIImageView *icon;
@end
@implementation CustomCell
- (UILabel *)titleLab{
    if (!_titleLab) {
        _titleLab = [[UILabel alloc] init];
    }
    return _titleLab;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
                [self createUI];
    }
    return self;
}
- (instancetype)initWithFrame:(CGRect)frame{

    if (self = [super initWithFrame:frame]) {
        [self createUI];
    }
    return self;
}
- (void)createUI{
    
    self.icon = [[UIImageView alloc] init];
    [self.contentView addSubview:self.icon];
    self.icon.backgroundColor = [UIColor redColor];
    [self.icon mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-15);
        make.top.mas_equalTo(10);
        make.size.mas_equalTo(CGSizeMake(130, 70));
        
    }];
    self.titleLab.text = @"王宝强支持赵薇被骂惨：还是管好自己的老婆吧";
    self.titleLab.numberOfLines=2;
    self.titleLab.textColor = [UIColor blueColor];
    [self.contentView addSubview:self.titleLab];
    [self.titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.top.mas_equalTo(10);
        make.right.mas_equalTo(self.icon.mas_left).mas_equalTo(-10);
    }];
    self.followLab = [[UILabel alloc] init];
    self.followLab.text = @"118";
    self.followLab.textColor = [UIColor blueColor];
    [self.contentView addSubview:self.followLab];
    [self.followLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.top.mas_equalTo(self.titleLab.mas_bottom).mas_equalTo(10);
    }];
    
    self.detailLab = [[UILabel alloc] init];
    self.detailLab.text = @"搜狐娱乐解决吗到几点";
    self.detailLab.textColor = [UIColor blueColor];
    [self.contentView addSubview:self.detailLab];
    [self.detailLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.followLab.mas_right).mas_equalTo(10);
        make.top.mas_equalTo(self.followLab);
        
    }];
    [self.detailLab setContentHuggingPriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];
    [self.detailLab setContentCompressionResistancePriority:UILayoutPriorityFittingSizeLevel forAxis:UILayoutConstraintAxisHorizontal];
    

    [self.detailLab setContentCompressionResistancePriority:UILayoutPriorityRequired forAxis:UILayoutConstraintAxisHorizontal];//不可以被压缩，尽量显示完整
    self.zhiBtn = [[UIButton alloc] init];
    [self.zhiBtn setTitle:@"置顶" forState:UIControlStateNormal];
    [self.zhiBtn setTitleColor:[UIColor redColor] forState:UIControlStateNormal];
    self.zhiBtn.titleLabel.font = [UIFont systemFontOfSize:15];
    self.zhiBtn.layer.cornerRadius = 3;
    self.zhiBtn.layer.masksToBounds=YES;
    self.zhiBtn.layer.borderColor = [UIColor redColor].CGColor;
    self.zhiBtn.layer.borderWidth = 1;
    [self.zhiBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.detailLab.mas_right).mas_equalTo(5);
        make.size.mas_equalTo(CGSizeMake(39, 22));
        make.centerY.mas_equalTo(self.detailLab);
    }];
}
- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    [self createUI];
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
